<?php

// INCLUDES

require_once("Smarty/Smarty.class.php");
require_once("propel/Propel.php");

include_once("metrix/Metric.php");
include_once("metrix/Prompt.php");
include_once("metrix/Team.php");
include_once("metrix/User.php");
include_once("metrix/UserTeam.php");

require_once("includes/functions.php");

// INITIALISATION

Propel::init("/opt/dev/php/workspace/metrix/build/conf/metrix-conf.php");

$smarty = new Smarty();

$smarty->template_dir = "templates";
$smarty->compile_dir = "/var/smarty/templates_c";
$smarty->cache_dir = "/var/smarty/cache";
$smarty->config_dir = "/var/smarty/configs";

$ctl_status = array();

$app_debug = true;

// GETS AND POSTS

$get_action = trim(strtolower($_GET["action"]));
$get_item = trim(strtolower($_GET["item"]));
$get_mode = trim(strtolower($_GET["mode"]));
$get_param = trim($_GET["param"]);

$post_form_id = trim(strtolower($_POST["form_id"]));

if($get_action=="") {
	$get_action = "view";
}

if($get_item=="") {
	$get_item = "home";
}

// ACTIONS

include("actions/login.action.php");
include("actions/form.user.action.php");
include("actions/form.metric.action.php");
include("actions/debug.action.php");

// SET VARIABLES

$smarty->assign("ctl_action",$get_action);
$smarty->assign("ctl_item",$get_item);
$smarty->assign("ctl_mode",$get_mode);
$smarty->assign("ctl_param",$get_param);

$smarty->assign("app_name","Metrix");
$smarty->assign("app_version","1.0");
$smarty->assign("app_user","TMS Accident Management");
$smarty->assign("app_debug",$app_debug);

$smarty->assign("ctl_status",$ctl_status);
if(count($ctl_status)>0) {
	$smarty->assign("ctl_status_display",true);
}

// OUTPUT TEMPLATE

if($get_action=="view") {
	$smarty->assign("page",$get_item);
	$smarty->display("page_index.tpl");
}


?>
